﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling;

namespace DSLFactory.VSCTDesigner
{
    partial class CommandHasParentSerializer
    {
        /// <summary>
        /// Calculates a monikerized string reference to a Command.
        /// </summary>
        /// <param name="serializationContext">Serialization context.</param>
        /// <param name="sourceElement">Source side of reference relationship. The referenced target element will be serialized.</param>
        /// <param name="targetElement">Target side of relationship that will be serialized.</param>
        /// <returns>
        /// A monikerized string reference to target element.
        /// </returns>
        public override string SerializeReference(Microsoft.VisualStudio.Modeling.SerializationContext serializationContext, Microsoft.VisualStudio.Modeling.ModelElement sourceElement, Microsoft.VisualStudio.Modeling.ModelElement targetElement)
        {
            // On ne veut pas la forme abrégée
            DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id);
            global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!");
            string targetMoniker = targetSerializer.CalculateQualifiedName(serializationContext.Directory, targetElement);
            return targetMoniker;
        }
    }
}
